<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/Model.php');
require_once($Config->WebCMSRoot.'Data/Map.php');

Class MapModel extends BaseModel
{
	var $Key;
	var $Name;
	var $Address;
	var $Latitude;
	var $Longitude;
	var $ZoomLevel;
	var $MapType;

	function MapModel($array = null)
	{
		$this->Key     = '';
		
		if (isset($array))
		{
			$this->Key = $array['Key'];

			parent::BaseModel($array['ID']);
		}
		else
		{
			parent::BaseModel();
		}
	}
	
	function Retrieve(&$parameters)
	{
		$db = new MapData();
		$this->Parameters = &$parameters;
//print('<pre>'.var_export($parameters, true).'</pre>');exit;
		
		$this->ID      = $this->GetParameter('id');
		$this->Key     = $this->GetParameter('key');
		$this->Address = $this->GetParameter('address');
		
//print('<pre>'.var_export($this, true).'</pre>');exit;
		if ($this->ID != -1)
		{
			$db->Retrieve(&$this);
		}
		else
		{
			$map = new MapModel();
			$map->Key = $this->Key;
			$this->Collection[0] = $map;
		}
//print('<pre>'.var_export($this, true).'</pre>');exit;
	}

	function Persist()
	{
		$db = new MapData();

		$db->Update(&$this);
	}
	
	function Delete()
	{
		$db = new MapData();
		$db->Delete(&$this);
	}
	
	/* Extended functions */
}
?>